﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using Model;

namespace Web.Admin
{
    public partial class Tags_Add : BaseCode.BaseAdmin
    {
        private DAL_Tags dalTags = new DAL_Tags();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string name = this.txtName.Text;
            string ename = this.txtEname.Text;
            string keyword = this.txtKeywords.Text;
            string remark = this.txtRemark.Text;
            string type = this.ddlType.SelectedValue;
            int state = (this.rbtnNoUse.Checked == true) ? 0 : 1;

            Model_Tags tag = new Model_Tags()
            {
                name = name,
                ename = ename,
                //levels = int.Parse(levels),
                keywords = keyword,
                remark = remark,
                tagtype = int.Parse(type),
                state = state,
                updatetime = DateTime.Now,
                addtime = DateTime.Now
            };
            if (dalTags.Add(tag) > 0)
            {
                Page.ClientScript.RegisterStartupScript(typeof(string), "提示", "<script>alert('添加成功！');</script>");
                Response.Redirect("Tags.aspx");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(typeof(string), "提示", "<script>alert('添加失败！');</script>");
                return;
            }
        }
    }
}